package com.wlyuan.open.domain.api.assembler;

import com.wlyuan.open.domain.api.OpenApi;
import com.wlyuan.open.domain.api.utils.MappingMethod;
import com.wlyuan.open.dto.api.OpenApiCreationDTO;
import com.wlyuan.open.dto.api.OpenApiUpdateDTO;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;

/**
 * @author yuanzheng
 */
public class OpenApiAssembler {

    @Mapper(uses = {MappingMethod.class})
    public interface Assembler {

        OpenApi assemble(OpenApiCreationDTO source);

        void assemble(@MappingTarget OpenApi openApi, OpenApiUpdateDTO source);

    }

    private static final Assembler ASSEMBLER = Mappers.getMapper(Assembler.class);

    public static OpenApi assemble(OpenApiCreationDTO source) {
        return ASSEMBLER.assemble(source);
    }

    public static void assemble(OpenApi openApi, OpenApiUpdateDTO source) {
        ASSEMBLER.assemble(openApi, source);
    }


}
